package pl.koziolekweb.szkola.NKBeans;

// NK-Beans/Bramkarz.java
 
import java.beans.*;

  // kontroler dla modelu Kibice
public class Bramkarz implements VetoableChangeListener {

      // wywolywana gdy zmieni sie model
    public void vetoableChange(PropertyChangeEvent e)
            throws PropertyVetoException {
        int[] kibice = (int[])e.getNewValue();
        double ratio;
        if (Math.max(kibice[0],kibice[1]) <=
                               Props.getIntProp("limit"))
            ratio = 0;
        else
            ratio = Math.abs(kibice[0]-kibice[1])/
                    (double)(kibice[0]+kibice[1]);

        if (ratio > Props.getDoubleProp("forbidden"))
            throw new PropertyVetoException(
                                    "ZMIANA ZABRONIONA",e);
    }
}
